﻿using System;
using System.Collections.Generic;


namespace AppMain
{
    //没有锚点
    public class Box3D : Box2D
    {
        //size        
        public float sizeY;
        //pos        
        public float posY;
        //offset        
        public float offsetY = 0;


        public Box3D(float sizeX, float sizeY, float sizeZ, float posX, float posY, float posZ, float offsetX, float offsetY, float offsetZ)
        {
            this.sizeX = sizeX;
            this.sizeY = sizeY;
            this.sizeZ = sizeZ;

            this.posX = posX;
            this.posY = posY;
            this.posZ = posZ;

            this.offsetX = offsetX;
            this.offsetY = offsetY;
            this.offsetZ = offsetZ;
        }
        public Box3D(Box3D source)
        {
            this.sizeX = source.sizeX;
            this.sizeY = source.sizeY;
            this.sizeZ = source.sizeZ;

            this.posX = source.posX;
            this.posY = source.posY;
            this.posZ = source.posZ;

            this.offsetX = source.offsetX;
            this.offsetY = source.offsetY;
            this.offsetZ = source.offsetZ;
        }

        public Box3D(float[] sizeLst, float[] offsetLst, float posX, float posY, float posZ)
        {
            this.sizeX = sizeLst[0];
            this.sizeY = sizeLst[1];
            this.sizeZ = sizeLst[2];

            this.posX = posX;
            this.posY = posY;
            this.posZ = posZ;

            this.offsetX = offsetLst[0];
            this.offsetY = offsetLst[1];
            this.offsetZ = offsetLst[2];
        }

        public Box3D(float sizeX, float sizeY, float sizeZ, float posX, float posY, float posZ)
        {
            this.sizeX = sizeX;
            this.sizeY = sizeY;
            this.sizeZ = sizeZ;

            this.posX = posX;
            this.posY = posY;
            this.posZ = posZ;

            this.offsetX = 0;
            this.offsetY = 0;
            this.offsetZ = 0;
        }

        public Box3D(float sizeX, float sizeZ, float posX, float posZ) : base(sizeX, sizeZ, posX, posZ)
        {
        }

        public override void updateSize(float[] sizeLst)
        {
            updateSize(sizeLst[0], sizeLst[1], sizeLst[2]);
        }

        public void updateSize(float sizeX, float sizeY, float sizeZ)
        {
            this.sizeX = sizeX;
            this.sizeY = sizeY;
            this.sizeZ = sizeZ;
        }

        public override void updateOffset(float[] offsetLst)
        {
            updateOffset(offsetLst[0], offsetLst[1], offsetLst[2]);
        }

        public void updateOffset(float offsetX, float offsetY, float offsetZ)
        {
            this.offsetX = offsetX;
            this.offsetY = offsetY;
            this.offsetZ = offsetZ;
        }



        public float yMin
        {
            get
            {
                return posY - sizeY * 0.5f + offsetY;
            }
        }

        public float yMax
        {
            get
            {
                return posY + sizeY * 0.5f + offsetY;
            }
        }

        public override string ToString()
        {
            return string.Format("pos: ({0},{1},{2})   size: ({3},{4},{5}) ", posX, posY, posZ, sizeX, sizeY, sizeZ);
        }


    }

}
